#include <QApplication>

#include "meta_center_server_ui.h"
#include "logger.h"


INITIALIZE_EASYLOGGINGPP;


enum DB_TYPE{
    UNKONWN = 0,
    DB_MYSQL = 1,
    DB_SQLITE = 2,
    DB_MONGO = 3
};

int g_db = 0;

int main(int argc, char *argv[])
{
    if(argc > 1)
    {
        if(std::string("dbmysql") == argv[1]){ g_db = DB_MYSQL; }
        else if(std::string("dbsqlite") == argv[1]){ g_db = DB_SQLITE; }
        else if((std::string("--help") == argv[1]) || (std::string("-h") == argv[1]) || (std::string("?") == argv[1]))
        {
            char helpinfo[] = "./a.out <DB_TYPE>, eg: meta_center_server dbsqlite";
            printf("usage: %s\n", helpinfo); //打印
            return 0;
        }
    }
    else if(argc == 1)
    {
        // g_db = DB_SQLITE;
        g_db = DB_MYSQL;
    }


    {
        // 只需要在 main() 开始时候初始化一次就够, 当然后续根据子集需要  defaultConf.set()  el::Loggers::reconfigureLogger,
        // defaultConf.setGlobally()   el::Loggers::reconfigureLogger(),
        el::Configurations defaultConf;
        defaultConf.set(el::Level::Info, el::ConfigurationType::Format, "%datetime %level %msg");
        defaultConf.setGlobally(el::ConfigurationType::Filename, "../log/meta_serv_log_%datetime{%Y%M%d_%H%m%s}.log");
        // "./log/log_%datetime{%Y%M%d_%H%m%s}.log"
        el::Loggers::reconfigureLogger("default", defaultConf);
    }

    MYLOG("start ...");

    QApplication a(argc, argv);
    MetaCenterServerUi w;
    w.show();
    return a.exec();
}
